﻿'========================================================================
'功能:網頁資料商業邏輯物件
'作者:andy
'日期: 2011/1/31
'========================================================================

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports System.Text
Imports System.Data
Namespace OAMS.BBL
    Public Class MenuBBL



        ''' <summary>
        ''' 取得有授權的Menu資料
        ''' </summary>
        ''' <param name="UID"></param>
        ''' <returns>取得有授權的Menu資料</returns>
        ''' <remarks>取得有授權的Menu資料</remarks>
        Public Function GetMenuUID(ByVal UID As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuUID(UID)
        End Function


        ''' <summary>
        ''' 取得有授權的Menu資料
        ''' </summary>
        ''' <param name="UID"></param>
        ''' <returns>取得有授權的Menu資料</returns>
        ''' <remarks>取得有授權的Menu資料</remarks>
        Public Function GetMenuByRootNameUID(ByVal RootName As String, ByVal UID As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuByRootNameUID(RootName, UID)
        End Function

        ''' <summary>
        ''' 取得畫面檔資料
        ''' </summary>
        ''' <returns>取得畫面檔資料</returns>
        ''' <remarks>取得畫面檔資料</remarks>
        Public Function GetMenu(ByVal dbName As String) As DataTable

            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenu()
        End Function
        ''' <summary>
        ''' 修改Memu資料
        ''' </summary>
        ''' <param name="ProgramID"></param>
        ''' <param name="RootName"></param>
        ''' <param name="Name"></param>
        ''' <param name="NeedControl"></param>
        ''' <param name="URL"></param>
        ''' <param name="GroupID"></param>
        ''' <param name="UID"></param>
        ''' <remarks>修改Memu資料</remarks>
        Public Sub UpdateMenu(ByVal ProgramID As Integer, ByVal RootName As String, ByVal Name As String, ByVal NeedControl As Boolean, ByVal URL As String, ByVal GroupID As String, ByVal UID As String, ByVal QueryString As Boolean, ByVal dbName As String, ByVal ChnName As String, _
                              ByVal EngName As String, ByVal IsMenu As Boolean, ByVal OrderByID As String, ByVal IsRoot As Boolean, ByVal IsNewWin As Boolean, ByVal Param As Integer, ByVal MenuType As Integer)
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            db1.UpdateMenu(ProgramID, RootName, Name, NeedControl, URL, GroupID, UID, QueryString, ChnName, EngName, IsMenu, OrderByID, IsRoot, IsNewWin, Param, MenuType)
        End Sub

        ''' <summary>
        ''' 新增一筆Menu資料
        ''' </summary>
        ''' <param name="RootName"></param>
        ''' <param name="Name"></param>
        ''' <param name="NeedControl"></param>
        ''' <param name="URL"></param>
        ''' <param name="GroupID"></param>
        ''' <param name="UID"></param>
        ''' <returns>新增一筆Menu資料</returns>
        ''' <remarks>新增一筆Menu資料</remarks>
        Public Function INSERT_NewOne(ByVal RootName As String, ByVal Name As String, ByVal NeedControl As Boolean, ByVal URL As String, ByVal GroupID As String, ByVal UID As String, ByVal dbName As String, ByVal IsMenu As Boolean, ByVal Admin As Boolean) As Integer
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.INSERT_NewOne(RootName, Name, NeedControl, URL, GroupID, UID, IsMenu, Admin)
        End Function
        ''' <summary>
        ''' 取得某一畫面權限
        ''' </summary>
        ''' <param name="ProgramID"></param>
        ''' <returns>取得某一畫面權限</returns>
        ''' <remarks>取得某一畫面權限</remarks>
        Public Function GetMenuRights(ByVal ProgramID As Integer, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuRights(ProgramID)
        End Function
        ''' <summary>
        ''' 新增或修改一筆MenuRights資料
        ''' </summary>
        ''' <param name="ProgramID"></param>
        ''' <param name="SeqNo"></param>
        ''' <param name="DisplayName"></param>
        ''' <param name="UID"></param>
        ''' <remarks>新增或修改一筆MenuRights資料</remarks>
        Public Sub UpdateMenuRights(ByVal ProgramID As Integer, ByVal SeqNo As Integer, ByVal DisplayName As String, ByVal UID As String, ByVal dbName As String)
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            db1.UpdateMenuRights(ProgramID, SeqNo, DisplayName, UID)
        End Sub

        ''' <summary>
        ''' 取得畫面檔資料
        ''' </summary>
        ''' <returns>取得畫面檔資料</returns>
        ''' <remarks>取得畫面檔資料</remarks>
        Public Function GetMenuByRootName(ByVal RootName As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuByRootName(RootName)
        End Function
        ''' <summary>
        ''' 取得選單名稱
        ''' </summary>
        ''' <returns>取得畫面檔資料</returns>
        ''' <remarks>取得畫面檔資料</remarks>
        Public Function GetRootName(ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetRootName()
        End Function


        ''' <summary>
        ''' 取得選單名稱
        ''' </summary>
        ''' <returns>取得畫面檔資料</returns>
        ''' <remarks>取得畫面檔資料</remarks>
        Public Function GetRootNameUID(ByVal UID As String, ByVal dbName As String) As DataTable

            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetRootNameUID(UID)
        End Function
        ''' <summary>
        ''' 檢查某個URL 是否已存在,要避免重復KeyIn
        ''' </summary>
        ''' <param name="URL"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Function UrlIsExist(ByVal URL As String, ByVal ProgramID As Integer, ByVal dbName As String) As Boolean
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.UrlIsExist(URL, ProgramID)
        End Function

        Public Function GetUserMenuByRootName(ByVal RootName As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetUserMenuByRootName(RootName)
        End Function


        Public Function GetMenuByRootNameUIDAllColumn(ByVal RootName As String, ByVal UID As String, ByVal GroupID As String, ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuByRootNameUIDAllColumn(RootName, UID, GroupID)
        End Function
        Public Function GetMenuByRootNameUIDMaxCol(ByVal RootName As String, ByVal UID As String, ByVal dbName As String) As Integer
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuByRootNameUIDMaxCol(RootName, UID)
        End Function
        Public Function GetMenuType(ByVal dbName As String) As DataTable
            Dim db1 As OAMS.DAO.MenuDAO = New OAMS.DAO.MenuDAO(dbName)
            Return db1.GetMenuType()
        End Function
    End Class
End Namespace

